package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.ShopProduct;
import com.addplus.townmall.server.api.model.town.StoreShopCategory;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商城商品自定义分类关联表 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-08-27
 */
public interface StoreShopCategoryMapper extends BaseAddMapper<StoreShopCategory> {

    @Select("SELECT p.id,p.shop_name,p.shop_seal_img,p.shop_describe,p.cost_price,p.line_price," +
            "p.sale_count+p.sale_virtual_count as sale_count\n" +
            "FROM shop_product p " +
            "LEFT JOIN store_shop_category c ON c.shop_id = p.id AND p.is_deleted = 0 AND p.audit_status=0 AND p.sale_status = 0 AND \n" +
            "c.is_deleted=0 WHERE p.store_id = #{store_id} AND c.store_category_id in #{categoryId} AND c.shop_id= #{store_id} ORDER BY p.sort")
    IPage<ShopProduct> getStoreShopProductByCategoryPage(Page page, @Param("categoryId") List<Integer> categoryId , @Param("store_id") Integer storeId);
}
